
import time
class SeatBooking:
    def check_bookings(self,seats):
        print("正在为您查询该场次电影预定状态...")
        time.sleep(0.7)
        print("从上到下是1~6排，从左到右是1~8座")
        print("===========================")
        for row in seats:
            time.sleep(0.1)
            print("  ".join(row))
        print("===========================")
        time.sleep(0.7)

    # 获取符合要求的行索引
    def get_row(self):
        input_row = input("预定第几排第几列的座位呢，请输入1~6之间的数字：")
        vaild_row = [str(i+1) for i in range(6)]
        while input_row not in vaild_row:
            input_row = input("没有按要求输入，请重新输入1~6之间的数字：")
        row = int(input_row)-1
        return row
    # 获取符合要求的列索引
    def get_col(self):
        input_column = input("预定这一排第几个座位呢？请输入1~8之间的数字：")
        vaild_column = [str(i+1) for i in range(8)]

        while input_column not in vaild_column:
            input_column = input("没有按要求输入，请输入1~8之间的数字：")
        column = int(input_column)-1
        return column
    #预定指定座位
    def book_seat(self, saets):
        while True:
            row = self.get_row()
            column = self.get_col()
            #指定座位没有被预定
            if saets[row][column] == "○":
                print("正在为您预定指定座位...")
                time.sleep(0.7)
                saets[row][column] = "●"
                print("预定成功！座位号{}排{}座".format(row+1,column+1))
                break
            else:
                print("这个座位已经被预定了哦，试试别的吧")
                time.sleep(0.7)
    def book_seat_at_front(self,seats):
        print("正在为您预定最靠前的座位...")
        time.sleep(0.7)
        for row in range(6):
            for column in range(8):
                if seats[row][column] == "○":
                    seats[row][column] = "●"
                    print("预定成功！座位号：{}排{}座".format(row+1, column+1))
                    return
        print("非常抱歉，所有座位被订满，无法为您保留座位")




